
/**
 *  This class is a mother class for all the other Uml* classes, this
 *  allows to generalize their management, declare virtual operations etc ...
 * 
 *  You can modify it as you want (except the constructor)
 */
abstract class UmlItem extends UmlBaseItem implements Comparable {
  public UmlItem(long id, String n){ super(id, n); }

  public void sort() {
    UmlCom.trace("target not allowed, must be a <i>package</i>, any <i>view</i>, or a <i>use case</i>");
  }

  public int compareTo(Object arg) {
    UmlItem e1 = (UmlItem)this;
    UmlItem e2 = (UmlItem)arg;
    
    int u1 = e1.orderWeight();
    int u2 = e2.orderWeight();
    
    return ( u1 != u2 ) ? ( u1 - u2 ) : e1.name().compareTo( e2.name() );
  }

  public int orderWeight() {
    return 0;
  }

  public void sortChildren() {
    UmlItem[] v = children();
    int sz = v.length;
    
    if ( sz != 0 ){
      java.util.Arrays.sort((Object[])v);
    
      UmlItem previous = null;
    
      for ( int u = 0; u != sz; u++ ){
        v[u].moveAfter(previous);
        previous = v[u];
      }
    }
  }

};
